﻿using System.Collections;
using System.Collections.Generic;
using Fyber;
using UnityEngine;

namespace com.yd.sdk.imp
{
    public class FyberInterstitialListener : InterstitialListener
    {
        public delegate void OnShowDelegate(string placementId, ImpressionData impressionData);
        public delegate void OnClickDelegate(string placementId);
        public delegate void OnHideDelegate(string placementId);
        public delegate void OnShowFailureDelegate(string placementId, ImpressionData impressionData);
        public delegate void OnAvailableDelegate(string placementId);
        public delegate void OnUnavailableDelegate(string placementId);
        public delegate void OnRequestStartDelegate(string placementId);

        public OnShowDelegate OnShowHandler;
        public OnClickDelegate OnClickHandler;
        public OnHideDelegate OnHideHandler;
        public OnShowFailureDelegate OnShowFailureHandler;
        public OnAvailableDelegate OnAvailableHandler;
        public OnUnavailableDelegate OnUnavailableHandler;
        public OnRequestStartDelegate OnRequestStartHandler;
        
        public void OnShow(string placementId, ImpressionData impressionData)
        {
            OnShowHandler?.Invoke(placementId, impressionData);
        }

        public void OnClick(string placementId)
        {
            OnClickHandler?.Invoke(placementId);
        }

        public void OnHide(string placementId)
        {
            //隐藏之后继续预加载
            Interstitial.Request(placementId);
            OnHideHandler?.Invoke(placementId);
        }

        public void OnShowFailure(string placementId, ImpressionData impressionData)
        {
            OnShowFailureHandler?.Invoke(placementId,impressionData);
        }

        public void OnAvailable(string placementId)
        {
            OnAvailableHandler?.Invoke(placementId);
        }

        public void OnUnavailable(string placementId)
        {
            OnUnavailableHandler?.Invoke(placementId);
        }

        public void OnRequestStart(string placementId)
        {
            OnRequestStartHandler?.Invoke(placementId);
        }
    }
}